package com.qf.erpb.sale.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.erpb.core.vo.PageVO;
import com.qf.erpb.sale.dao.ShoppinginfoDao;
import com.qf.erpb.sale.entity.ShoppingVo;
import com.qf.erpb.sale.entity.Shoppinginfo;
import com.qf.erpb.sale.param.ShoppingParam;
import com.qf.erpb.sale.service.ShoppinginfoService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * (Shoppinginfo)表服务实现类
 *
 * @author makejava
 * @since 2023-12-22 14:50:01
 */
@Service("shoppinginfoService")
public class ShoppinginfoServiceImpl extends ServiceImpl<ShoppinginfoDao, Shoppinginfo> implements ShoppinginfoService {
    @Resource
    private ShoppinginfoDao shoppinginfoDao;


    //    分页加模糊查询
    @Override
    public PageVO<ShoppingVo> pageShopping(ShoppingParam shoppingParam) {
        Page<ShoppingVo> page = new Page<>(shoppingParam.getPageNum(), shoppingParam.getPageSize());
        QueryWrapper<ShoppingVo> wrapper = new QueryWrapper<ShoppingVo>();
        //      if 判断 模糊查询的
        if (StringUtils.hasLength(shoppingParam.getContactPeople())) {
            wrapper.like("contact_people", shoppingParam.getContactPeople());
        }
        if (StringUtils.hasLength(shoppingParam.getContactPeople())) {
            wrapper.like("shopping_name", shoppingParam.getContactPeople());
        }
        page = (Page<ShoppingVo>) shoppinginfoDao.selectAll(page, wrapper);
        PageVO<ShoppingVo> pageVO = new PageVO<>();
        pageVO.setTotal(page.getTotal());
        pageVO.setDataList(page.getRecords());
        return pageVO;

    }
}
